package com.lbmb.mdps.settings.controller;

import com.lbmb.mdps.commons.constant.Constant;
import com.lbmb.mdps.commons.domain.ChartVo;
import com.lbmb.mdps.commons.domain.ReturnObjectVO;
import com.lbmb.mdps.commons.exception.AdministratorException;
import com.lbmb.mdps.commons.exception.EmployeeException;
import com.lbmb.mdps.commons.exception.MedicineException;
import com.lbmb.mdps.commons.exception.MedicineTypeException;
import com.lbmb.mdps.commons.utils.Md5Util;
import com.lbmb.mdps.settings.domain.Administrator;
import com.lbmb.mdps.settings.service.ChartService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 林文塨
 * @date 2022-06-02 12:56
 * description
 */
@CrossOrigin
@RestController
public class ChartController {

    @Resource
    private ChartService chartService;

    @GetMapping( "/settings/chart/initMedicineTypePieChart.do")
    public ReturnObjectVO initMedicineTypePieChart() throws MedicineTypeException, MedicineException {
        /*
         * 获得药品类别饼状图数据
         * @author 林文塨
         * @date 2022/6/2 12:57
         * @param [administrator]
         * @return com.lbmb.mdps.commons.domain.ReturnObjectVO
         */

        ReturnObjectVO rov = new ReturnObjectVO();

        List<ChartVo> chartVoList = chartService.initMedicineTypePieChart();

        rov.setCode(Constant.RETURN_OBJECT_CODE_SUCCESS);
        rov.setOthers(chartVoList);

        return rov;
    }

    @GetMapping( "/settings/chart/initMedicineAttributePieChart.do")
    public ReturnObjectVO initMedicineAttributePieChart() {
        /*
         * 获得药品属性饼状图数据
         * @author 林文塨
         * @date 2022/6/2 12:57
         * @param [administrator]
         * @return com.lbmb.mdps.commons.domain.ReturnObjectVO
         */

        ReturnObjectVO rov = new ReturnObjectVO();

        List<ChartVo> chartVoList = chartService.initMedicineAttributePieChart();

        rov.setCode(Constant.RETURN_OBJECT_CODE_SUCCESS);
        rov.setOthers(chartVoList);

        return rov;
    }

    @GetMapping( "/settings/chart/initEmployeePurchasePieChart.do")
    public ReturnObjectVO initEmployeePurchasePieChart() throws EmployeeException {
        /*
         * 获得员工采购饼状图数据
         * @author 林文塨
         * @date 2022/6/2 12:57
         * @param [administrator]
         * @return com.lbmb.mdps.commons.domain.ReturnObjectVO
         */

        ReturnObjectVO rov = new ReturnObjectVO();

        List<ChartVo> chartVoList = chartService.initEmployeePurchasePieChart();

        rov.setCode(Constant.RETURN_OBJECT_CODE_SUCCESS);
        rov.setOthers(chartVoList);

        return rov;
    }

    @GetMapping( "/settings/chart/initEmployeeDeliverPieChart.do")
    public ReturnObjectVO initEmployeeDeliverPieChart() throws EmployeeException {
        /*
         * 获得员工出库饼状图数据
         * @author 林文塨
         * @date 2022/6/2 12:57
         * @param [administrator]
         * @return com.lbmb.mdps.commons.domain.ReturnObjectVO
         */

        ReturnObjectVO rov = new ReturnObjectVO();

        List<ChartVo> chartVoList = chartService.initEmployeeDeliverPieChart();

        rov.setCode(Constant.RETURN_OBJECT_CODE_SUCCESS);
        rov.setOthers(chartVoList);

        return rov;
    }
}
